Skip to content

feat: creating and removing empty directories #1011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

wassup05
Copy link
Contributor

@wassup05 wassup05 commented Jul 1, 2025

User facing functions added are

  • make_directory (path, mode, err) (mode argument only for Unix systems)
  • remove_directory (path, err)
  1. Both of them support relative paths and on Windows, paths involving either / or \.
  2. They bind to the CRT functions mkdir, rmdir, _mkdir, _rmdir on Unix and Windows respectively.
  3. A binding to strerror has been included as a private helper to provide helpful error messages.
  4. state_type is used for error handling.

Side note:
make_directory could have a logical argument recursive which would work like mkdir -p but that would require path manipulation especially dir_name from #999

Do let me know your thoughts.

@sebastian-mutz
Copy link
Contributor

Hey @wassup05. Thanks for the PR. Great work!

  1. I added minor suggestions to the comments (just grammar).
  2. For example_remove_directory, I wonder if it makes sense to first create the directory. Ideally an example only demonstrates the use of one procedure, but without the existing directory, it can't. Just a thought and nothing major.

!!
!! ### Description
!! This function makes an empty directory according to the path provided.
!! Relative paths as well as on Windows paths involving either `/` or `\` are accepted
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add period to end of sentence.

!! ### Description
!! This function makes an empty directory according to the path provided.
!! Relative paths as well as on Windows paths involving either `/` or `\` are accepted
!! appropriate error message is returned whenever any error occur.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalise "appropriate" to be consistent. (Same down below).

@wassup05
Copy link
Contributor Author

wassup05 commented Jul 9, 2025

For example_remove_directory, I wonder if it makes sense to first create the directory. Ideally an example only demonstrates the use of one procedure, but without the existing directory, it can't. Just a thought and nothing major.

I think it's fine @sebastian-mutz, doing that would kind of clutter the example I feel, and this is how it's been handled in some other examples as well like here and here

@sebastian-mutz
Copy link
Contributor

For example_remove_directory, I wonder if it makes sense to first create the directory. Ideally an example only demonstrates the use of one procedure, but without the existing directory, it can't. Just a thought and nothing major.

I think it's fine @sebastian-mutz, doing that would kind of clutter the example I feel, and this is how it's been handled in some other examples as well like here and here

Makes sense. Then it's best to keep it consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants